#ifndef _WMI_REGISTRYMANAGER_H
#define _WMI_REGISTRYMANAGER_H

/******************************************************************************
** @file	wmi_registrymanager.h
** @author	Arturo Aguilar Tapia
**
** @date	Jul 22, 2010
**
** @desc	This class is created for load registrys from especific root and especific subKey 
**			this class contains methods that manipulate system registry keys and values
**			This class using StdRegProv Class and using EnumKey and EnumValues methods
**			for more documentation about StdRegProv visit http://msdn.microsoft.com/en-us/library/aa393664(VS.85).aspx
**
**			You can use the methods to perform the following tasks:
**
**			-Enumerate, registry keys.
**			-Enumerate, named values.
**			
**
******************************************************************************/

#include <comdef.h>
#include <Wbemidl.h>
#include <string>
#include "wmi_connection.h"
#include "wmi_registry.h"
#include "wmi_constants.h"
#include <log4cxx\logger.h>
#include <log4cxx\xml\domconfigurator.h>
#include "wmi_common.h"

class SOEXPORT WMI_RegistryManager
{
public:
	/**
	* Constructor of WMI_RegistryManager
	*
	* @param WMI_Connection, it's a necesari wmi_connection to execute methods of manager	
	*/
	WMI_RegistryManager(WMI_Connection* con);
	~WMI_RegistryManager(void);

	/**
	* getRegistrys Method Insert all Registry into rClass WMI_Registry param from especific root and especific SubKey
	*
	* @param root, it's a HiveEnum it represents a Hive of the registry for example HKEY_CLASSES_ROOT
	* @param subKey, a wstring that represents a subKey of the resgitry 
	* @param WMI_Registry is a registry class to load registry in this class
	*/
	WMI_HResult*
	getRegistrys(HiveEnum root, std::wstring SubKey, WMI_Registry** rClass);

	/**
	* getRegistrys Method Overload
	*
	* @param WMI_Registry is a registry class to load registry in this class
	*/
	WMI_HResult*
	getRegistrys(WMI_Registry** rClass);

	/**
	* LoadMethod Load Values into rClass return tru if the rClass contains Values
	*
	* @param rClass is a WMI_Registry class to load registry in this class
	*/
	WMI_HResult*
	LoadValues(WMI_Registry** rClass);

	void
	getStandardRegistryHives(std::vector<WMI_Registry>& standarRegistrys);

   /**
    * Returns the parent folder name.
    *
    * @param path from the parent will be extracted.
    * @return the parent container name.
    */
	void 
    getRegistryName(const wstring& path, wstring& outRoot, wstring& outRegistryName);

    /**
    *
    */
    void 
    getRegistrySubkey(const wstring& path, wstring& outRegistryName);

    int 
    getParseRoot(wstring path, wstring& root, wstring& subKey );

    HiveEnum 
	convertStringToHKEY(wstring strKey);

    wstring
	convertHiveEnumToWstring(HiveEnum hive);

// Private methods
private:

    /**
	* getMethod is a Method for return IWbemClassObject contains StrRegProv instance
	* and this istance is returned into pOutParam outputParam
	*
	* @param root, it's a HiveEnum it represents a Hive of the registry for example HKEY_CLASSES_ROOT
	* @param subKey, a wstring that represents a subKey of the resgitry 
	* @param NameMethod, a wchar_t* that represents the name of method present into StrRegProv example(EnumKey,EnumValues)
	* @param pOutParam is a IWemClassObject** output param is a class to load registry into this class
	* @param ValueName is optional wstring represent especific Name of Value for find Value
	*/
	WMI_HResult* 
	getMethod(HiveEnum root, std::wstring subKey, std::wstring nameMethod, IWbemClassObject** pOutParams, std::wstring ValueName);

	/**
	* getStringValue Method Return Value of especific Registry Value
	*
	* @param root, it's a HiveEnum it represents a Hive of the registry for example HKEY_CLASSES_ROOT
	* @param subKey, a wstring that represents a subKey of the resgitry 
	* @param valueName is a wstring that represent name of Value a to evaluate
	* @param valueString is a wstring output  param contains StringValue of Value
	*/
	WMI_HResult* 
	getStringValue(HiveEnum root, std::wstring subKey, std::wstring valueName, std::wstring valueString);

// Attributes
private:
	/**
	* Necesary wmi_connection for execute methods from StrRegProv Class
	*/
	WMI_Connection* _con;

	/**
	* _pClass IWebemClassObject contains an instance of StrRegProv Class
	*/
	IWbemClassObject*_pClass;

	/**
	* _ClassName BSTR contains the name of StrRegProv Class
	*/
	BSTR _ClassName;

	
};
#endif